local t = Def.ActorFrame {};
local event = GAMESTATE:IsEventMode();
local failed = STATSMAN:GetCurStageStats():AllFailed();
local exget = GAMESTATE:HasEarnedExtraStage();
local ex = GAMESTATE:IsExtraStage();
local ex2 = GAMESTATE:IsExtraStage2();

if exget and ex then
	t[#t+1] = LoadActor("_es")..{};
end

t[#t+1] = Def.ActorFrame {
	InitCommand=function(self) self:xy(SCREEN_CENTER_X,SCREEN_TOP+25):zoom(0.6):zoomy(0):diffusealpha(1) end;
	OnCommand=function(self) self:sleep(0.2):linear(0.15):zoomy(0.6) end;
	OffCommand=function(self) self:sleep(0.2):linear(0.15):zoomx(1):zoomy(0) end;
	LoadActor("_headerframe")..{
		InitCommand=function(self)
			if ex2 and exget then
				self:sleep(3.4):queuecommand("Vibe1")
			elseif ex2 and failed and not exget then
				self:visible(false)
			end
		end;
		Vibe1Command=function(self) self:vibrate():effectmagnitude(3,3,3):sleep(0.2):queuecommand("Vibe2") end;
		Vibe2Command=function(self) self:vibrate():effectmagnitude(6,6,6):sleep(0.2):queuecommand("Vibe3") end;
		Vibe3Command=function(self) self:vibrate():effectmagnitude(9,9,9):sleep(0.2):queuecommand("Vibe4") end;
		Vibe4Command=function(self) self:vibrate():effectmagnitude(12,12,12):sleep(0.2):queuecommand("Vibe5") end;
		Vibe5Command=function(self) self:vibrate():effectmagnitude(15,15,15):sleep(0.2):queuecommand("Vibe6") end;
		Vibe6Command=function(self) self:vibrate():effectmagnitude(18,18,18):sleep(0.2):queuecommand("Vibe7") end;
		Vibe7Command=function(self) self:vibrate():effectmagnitude(21,21,21):sleep(0.1):queuecommand("Vibe0") end;
		Vibe0Command=function(self) self:vibrate():effectmagnitude(1,1,1) end;
	};
	LoadActor("_results")..{
		InitCommand=function(self) self:diffusealpha(0) end;
		OnCommand=function(self)
			local name = SCREENMAN:GetTopScreen():GetNextScreenName();
			if name == "ScreenEvaluationSummary" or name == "ScreenGameOver" or name == "ScreenEnding" then
				self:sleep(0.5):queuecommand("FlickerOn")
			elseif name == "ScreenEvaluationSummary" and ex2 then
				self:sleep(0.5)
			elseif ex2 and not exget then
				self:sleep(0.5)
			elseif event == false and failed == true then
				self:sleep(0.5)
			elseif ex2 and exget then
				self:sleep(0.5):playcommand("FlickerOn"):sleep(2.75):queuecommand("Vibe1")
			else
				self:sleep(0.5):queuecommand("FlickerOn")
			end
		end;
		OffCommand=function(self) 
			if ex2 and not exget then
				self:sleep(0.5)
			elseif event == false and failed == true then
				self:sleep(0.5)
			else
				self:queuecommand("FlickerOff")
			end
		end;
		Vibe1Command=function(self) self:vibrate():effectmagnitude(3,3,3):sleep(0.2):queuecommand("Vibe2") end;
		Vibe2Command=function(self) self:vibrate():effectmagnitude(6,6,6):sleep(0.2):queuecommand("Vibe3") end;
		Vibe3Command=function(self) self:vibrate():effectmagnitude(9,9,9):sleep(0.2):queuecommand("Vibe4") end;
		Vibe4Command=function(self) self:vibrate():effectmagnitude(12,12,12):sleep(0.2):queuecommand("Vibe5") end;
		Vibe5Command=function(self) self:vibrate():effectmagnitude(15,15,15):sleep(0.2):queuecommand("Vibe6") end;
		Vibe6Command=function(self) self:vibrate():effectmagnitude(18,18,18):sleep(0.2):queuecommand("Vibe7") end;
		Vibe7Command=function(self) self:vibrate():effectmagnitude(21,21,21):sleep(0.1):queuecommand("Vibe0") end;
		Vibe0Command=function(self) self:vibrate():effectmagnitude(1,1,1) end;
		FlickerOnCommand=function(self) self:diffusealpha(1):sleep(0.03):diffusealpha(0):sleep(0.03):diffusealpha(1):sleep(0.03):diffusealpha(0):sleep(0.03):diffusealpha(1) end;
		FlickerOffCommand=function(self) self:diffusealpha(0):sleep(0.03):diffusealpha(1):sleep(0.03):diffusealpha(0):sleep(0.03):diffusealpha(1):sleep(0.03):diffusealpha(0) end;
	};
	LoadActor("_ACfailresult")..{
		Condition=failed and not event;
		InitCommand=function(self) self:diffusealpha(0) end;
		OnCommand=function(self)
			if ex2 and not exget then
				self:sleep(0.7)
			else
				self:sleep(0.7):queuecommand("Blink")
			end
		end;
		OffCommand=function(self) 
			if ex2 and not exget then
				self:sleep(0.5)
			else
				self:stoptweening():queuecommand("FlickerOff")
			end
		end;
		BlinkCommand=function(self) self:diffusealpha(1):sleep(0.3):diffusealpha(0):sleep(0.3):queuecommand("Blink") end;
		FlickerOffCommand=function(self) self:diffusealpha(0):sleep(0.03):diffusealpha(1):sleep(0.03):diffusealpha(0):sleep(0.03):diffusealpha(1):sleep(0.03):diffusealpha(0) end;
	};
	Def.Sprite {
	Texture=failed and "_consumed" or "_survived";
	Condition=ex2 and not exget;
	InitCommand=function(self)
		self:zoom(0.8):visible(true)
		local curScreen = Var "LoadingScreen";
		if curScreen == "ScreenEvaluationSummary" then
			self:visible(false)
		end
	end;
	OnCommand=function(self) self:queuecommand("GlitchFlicker")
		if failed then
			self:vibrate()
		end
	end;
	OffCommand=function(self) self:queuecommand("FlickerOff") end;
	GlitchFlickerCommand=function(self) self:sleep(math.random()):diffusealpha(0):sleep(0.05):diffusealpha(1):queuecommand("GlitchFlicker") end;
	FlickerOffCommand=function(self) self:diffusealpha(0):sleep(0.03):diffusealpha(1):sleep(0.03):diffusealpha(0):sleep(0.03):diffusealpha(1):sleep(0.03):diffusealpha(0) end;
	};
};


return t;